<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-for作业讲解</title>
    <style>
        .active{color:red}
        #app{background-color: grey;}
    </style>
</head>

<body>
    <!-- 
        v-for作业：
        要求遍历数组，且数组第一项字体颜色为红色，点击任意一项，该项字体显示为红色，其他不为红色
     -->
    <ul id="app">
        <li v-for="(item,index) in movies" :class="{active:currentIndex===index }" @click="btnClick(index)">
            {{index}}.{{item}}
        </li>
    </ul>

    <script src="./js/vue.min.js"></script>
    <script>
        const app = new Vue({
            el:'#app',
            data:{
                movies:['冰雪奇缘','黑猫警长','葫芦娃','小猪佩奇','天眼神虎','巴啦啦小魔仙','美人鱼','小鲤鱼历险记'],
                currentIndex:0,
            },
            methods:{
                btnClick(index) {
                    this.currentIndex = index;
                }
            },
            computed:{

            }
        })
    </script>
</body>

</html>